package com.cctc.rds.nrpc.demo.server;

import com.cctc.rds.nrpc.api.rpc.RpcServerRouter;
import com.cctc.rds.nrpc.api.server.config.RpcServerConfig;
import com.cctc.rds.nrpc.core.server.NettyRpcServer;
import com.cctc.rds.nrpc.demo.rpc.HelloRpc;
import com.cctc.rds.nrpc.demo.rpc.impl.HelloRpcResponseImpl;
import com.cctc.rds.nrpc.demo.rpc.router.DemoServerRpcRouter;

public class NettyRpcServerDemo {

    public static void main(String[] args) {
        HelloRpc helloRpc = new HelloRpcResponseImpl();
        RpcServerRouter router = new DemoServerRpcRouter(helloRpc);
        NettyRpcServer server = new NettyRpcServer(router);

        RpcServerConfig config = RpcServerConfig.builder()
                .port(9000)
                .workerThreads(Runtime.getRuntime().availableProcessors())
                .idleStateMs(300)
                .build();
        server.start(config);
    }

}
